package com.wannengbang.storemobile.a_main;


import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;

import com.alibaba.sdk.android.push.AndroidPopupActivity;
import com.wannengbang.storemobile.login.LoginActivity;
import com.wannengbang.storemobile.utils.SPManager;

import java.util.Map;

public class PopupPushActivity extends AndroidPopupActivity {
    static final String TAG = "PopupPushActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    /**
     * 实现通知打开回调方法，获取通知相关信息
     *
     * @param title   标题
     * @param summary 内容
     * @param extMap  额外参数
     */
    @Override
    protected void onSysNoticeOpened(String title, String summary, Map<String, String> extMap) {
        Log.d(TAG, "OnMiPushSysNoticeOpened, title: " + title + ", content: " + summary + ", extMap: " + extMap);

        Intent intent = null;
        // 跳转的Activity
        if (!TextUtils.isEmpty(SPManager.getInstance().getToken())) {
            intent = new Intent(PopupPushActivity.this, MainActivity.class);
        } else {
            intent = new Intent(PopupPushActivity.this, LoginActivity.class);
        }
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
    }
}
